'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var MobileLabelPush = function (_React$Component) {
    _inherits(MobileLabelPush, _React$Component);

    function MobileLabelPush(props) {
        _classCallCheck(this, MobileLabelPush);

        var _this = _possibleConstructorReturn(this, (MobileLabelPush.__proto__ || Object.getPrototypeOf(MobileLabelPush)).call(this, props));

        _this.pageCount = 0;
        _this.state = {
            list: [''],
            inputValues: {
                title: '',
                content: '',
                comms: 'mobile'
            }
        };
        return _this;
    }

    _createClass(MobileLabelPush, [{
        key: 'componentDidMount',
        value: function componentDidMount() {
            this.verify = {
                name: function name(value) {
                    if (value.length < 2) {
                        return '标题至少得2个字符!';
                    }
                },
                type: function type(value) {
                    if (value.length < 2) {
                        return '内容至少得2个字符!';
                    }
                }
            };
            this.refs.table.refresh();
        }
    }, {
        key: 'inputChange',
        value: function inputChange(type, value) {
            this.state.inputValues[type] = value;
            this.setState({});
        }
    }, {
        key: 'btnSubmit',
        value: function btnSubmit() {
            var _this2 = this;

            this.state.inputValues.type = 2;
            postJson("/NoticeCtrl/addNotice.x", this.state.inputValues, function (data) {
                console.log("data", data);
                layer.msg('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;添加成功', { icon: 6 });
                _this2.refs.table.refresh();
                _this2.refs.modal_add.close();
            });
        }
    }, {
        key: 'updateList',
        value: function updateList(page, pageSize) {
            var _this3 = this;

            var param = {};
            param.pageSize = pageSize;
            param.page = page;
            param.commCode = "mobile";
            postJson("/NoticeCtrl/queryNoticePage.x", $.param(param), function (data) {
                console.log("data", data);
                var list = data.list;
                _this3.pageCount = data.size;
                _this3.setState({
                    list: list
                });
            });
        }
    }, {
        key: 'search',
        value: function search() {
            this.refs.table.refresh();
        }
    }, {
        key: 'addNotice',
        value: function addNotice() {
            this.refs.modal_add.show();
        }
    }, {
        key: 'endCallback',
        value: function endCallback() {
            this.setState({
                inputValues: {
                    title: '',
                    content: '',
                    comms: 'mobile'
                }
            });
        }
    }, {
        key: 'render',
        value: function render() {
            var _this4 = this;

            return React.createElement(
                Frame,
                { header: '\u624B\u673A\u5168\u91CF\u63A8\u9001', headerBtns: React.createElement(
                        HeaderBtn,
                        { onClick: function onClick() {
                                return _this4.addNotice();
                            } },
                        React.createElement('i', { className: 'fa fa-plus' }),
                        '\xA0 \u6DFB\u52A0\u63A8\u9001'
                    ) },
                React.createElement(
                    Form,
                    { type: 'pane' },
                    React.createElement(
                        Table,
                        { ref: 'table', count: this.pageCount,
                            pageOnClick: function pageOnClick(page, pageSize) {
                                return _this4.updateList(page, pageSize);
                            } },
                        React.createElement(
                            'colgroup',
                            null,
                            React.createElement('col', null),
                            React.createElement('col', null),
                            React.createElement('col', null)
                        ),
                        React.createElement(
                            'thead',
                            null,
                            React.createElement(
                                'tr',
                                null,
                                React.createElement(
                                    'th',
                                    null,
                                    '\u6807\u9898'
                                ),
                                React.createElement(
                                    'th',
                                    null,
                                    '\u53D1\u5E03\u65F6\u95F4'
                                ),
                                React.createElement(
                                    'th',
                                    null,
                                    '\u53D1\u5E03\u5185\u5BB9'
                                )
                            )
                        ),
                        React.createElement(
                            'tbody',
                            null,
                            this.state.list.map(function (array) {
                                return React.createElement(
                                    'tr',
                                    null,
                                    React.createElement(
                                        'td',
                                        null,
                                        array.titile
                                    ),
                                    React.createElement(
                                        'td',
                                        null,
                                        array.create_time
                                    ),
                                    React.createElement(
                                        'td',
                                        null,
                                        array.context
                                    )
                                );
                            })
                        )
                    )
                ),
                React.createElement(
                    Modal,
                    {
                        area: ['800px'],
                        title: '\u6DFB\u52A0\u63A8\u9001',
                        ref: 'modal_add',
                        endCallback: function endCallback() {
                            return _this4.endCallback();
                        } },
                    React.createElement(
                        Form,
                        { type: 'pane', verify: function verify() {
                                return _this4.verify;
                            } },
                        React.createElement(
                            Item,
                            null,
                            React.createElement(
                                Label,
                                null,
                                '\u63A8\u9001\u6807\u9898'
                            ),
                            React.createElement(Input, { type: 'text',
                                block: true,
                                value: this.state.inputValues.title,
                                'lay-verify': 'title',
                                onChange: function onChange(value) {
                                    return _this4.inputChange('title', value);
                                },
                                placeholder: '\u8BF7\u8F93\u5165\u63CF\u8FF0'
                            })
                        ),
                        React.createElement(
                            Item,
                            { className: 'layui-form-item layui-form-text' },
                            React.createElement(
                                Label,
                                null,
                                '\u63A8\u9001\u5185\u5BB9'
                            ),
                            React.createElement(Textarea, { 'lay-verify': 'content', name: 'content', ref: 'content',
                                value: this.state.inputValues.content,
                                onChange: function onChange(value) {
                                    return _this4.inputChange('content', value);
                                } })
                        ),
                        React.createElement(
                            Item,
                            null,
                            React.createElement(
                                Button,
                                { formBtn: true,
                                    btnType: 'normal',
                                    onClick: function onClick() {
                                        return _this4.btnSubmit();
                                    } },
                                '\u786E\u5B9A\u63A8\u9001'
                            )
                        )
                    )
                )
            );
        }
    }]);

    return MobileLabelPush;
}(React.Component);

ReactDOM.render(React.createElement(MobileLabelPush, null), document.getElementById('root'));